#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define str string
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ms(a,t) memset(a,t,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) ((x)&(-(x)))
const ll INF = 0x3f3f3f3f;
const int maxn = 2e5+10;
const int maxm = 1e6+10;
const ll mod = 998244353;
const db eps = 1e-6;
int n,m;
ll L,V;
ll d[maxn],v[maxn],a[maxn],p[maxn];
int vec[maxm];
bool check(int id,int x) {
	ll s = v[id]*v[id]+2*a[id]*(p[x]-d[id]);
//	if(s <= V*V) cerr<<setprecision(6)<<fixed<<sqrt(s)<<'\n';
	return s > V*V;
}
void Solve() {
	cin >> n >> m >> L >> V;
	for(int i = 1; i <= n; i++) {
		cin >> d[i] >> v[i] >> a[i];
	}
	for(int i = 1; i <= m; i++) {
		cin >> p[i]; vec[i] = INF;
	}
	int num = 0;
	for(int i = 1; i <= n; i++) {
		if(d[i] > p[m]) continue;
		int l = 1,r = m;
		l = lower_bound(p+1,p+m+1,d[i])-p;
		if(a[i] > 0) {
			if(v[i]*v[i]+2*a[i]*(p[m]-d[i]) <= V*V) continue;
			l = upper_bound(p+l,p+m+1,d[i]+ceil(1.0*(V*V-v[i]*v[i])/(2*a[i])))-p;
			r = m;
		} else if(a[i] < 0) {
//			cerr<<l<<' '<<p[l]<<' '<<d[i]<<' '<<v[i]<<' '<<v[i]+a[i]*(p[l]-d[i])<<' '<<V<<'\n';
			if(v[i] <= V) continue;
			if(v[i]*v[i]+2*a[i]*(p[l]-d[i]) <= V*V) continue;
			r = lower_bound(p+l,p+m+1,d[i]+floor(1.0*(V*V-v[i]*v[i])/(2*a[i])))-p-1;
		} else {
			if(v[i] <= V) continue;
			r = m;
		}
//		int nl = l;
//		cerr<<l<<' '<<r<<' '<<V<<' '<<d[i]<<' '<<v[i]<<' '<<a[i]<<' '<<p[l]<<' '<<p[r]<<'\n';
		while(r < m && check(i,r+1)) r++;
		while(l > 1 && check(i,l-1) && p[l-1] >= d[i]) l--;
//		cerr<<l<<' '<<nl<<' '<<V<<' '<<sqrt(v[i]*v[i]+2*a[i]*(p[l]-d[i]))<<' '<<d[i]<<' '<<ceil(1.0*(V*V-v[i]*v[i])/(2*a[i]))<<'\n';
//		assert(abs(l-nl) <= 1);
		assert(check(i,l)); assert(check(i,r));
		num++;
		vec[l] = min(vec[l],r);
	}
	int cur = INF,cnt = 0;
	for(int i = 1; i <= m; i++) {
		cur = min(cur,vec[i]);
		if(cur == i) {
			cnt++; cur = INF;
		}
	}
	cout<<num<<' '<<m-cnt<<'\n';
//	cerr<<"ok"<<'\n';
	for(int i = 1; i <= m; i++) p[i] = 0;
	for(int i = 1; i <= n; i++) d[i] = v[i] = a[i] = 0;
}
int main() {
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int tt; cin >> tt; while(tt--)
	Solve();
	return 0;
}
